/**
 *	打印出警告信息
 */
var alert_border_color	=	"#FF24FF";
var alert_bg_color	=	"#FFECFF";

function alert(	msg	){
	response.print(	"<pre style='border:1px solid "	+	alert_border_color	+	
					";border-top:2px solid "	+	alert_border_color	+
					";background:"	+	alert_bg_color	+
					";font-size:11px;padding:5px;color:"	+	alert_border_color	+
					";clear:both;'>"	);
	response.print(	msg	);
	response.print(	"</pre>"	);
}
/**
 *	打印出调试信息
 */
var show_border_color	=	"#FF24FF";
var show_bg_color	=	"#FFECFF";
function show(	msg	){
	var code		=	"<div style='border:1px solid "	+	show_border_color	+	
						";background:"	+	show_bg_color	+
						";font-size:11px;padding:5px;color:"	+	show_border_color	+
						";clear:both;margin:0;margin-top:10px;'>";
	code			+=	"<pre style='padding:0;margin:0;'>";
	code			+=	msg;
	code			+=	"</pre>";
	code			+=	"</div>";
	response.print(	code	);}
var info_border_color	=	"#0080FF";
var info_bg_color	=	"#E1F0FF";
var default_info_title	=	"info";
var static_int	=	0;
function info(	msg,	title	){
	static_int	+=1;
	var code	=	"<div style='border:1px solid "	+	info_border_color	+	
					";border-top:2px solid "	+	info_border_color	+
					";background:"	+	info_bg_color	+
					";font-size:11px;padding:5px;color:"	+	info_border_color	+
					";clear:both;margin:0;margin-top:10px;' ";
	code		+=	"onclick='document.getElementById(\"debug_info_id_"	+	static_int	+	"\").style.display=\"\"'";
	code		+=	">";
	if(	$chk(title)	){
		code		+=	title;
	}else{
		code		+=	default_info_title;
	}
	//code		+=	"|<a href=\"#\" onclick=\"javascript:document.getElementById(\'debug_info_id_"	+	static_int	+	"\').style.display=\'none\';\">close</a>";
	code		+=	"</div>"
	code			+=	"<div style='border:1px solid "	+	info_border_color	+	
						";border-top:0px solid "	+	info_border_color	+
						";background:"	+	info_bg_color	+
						";font-size:11px;padding:5px;color:"	+	info_border_color	+
						";clear:both;display:none;' "+
						"id='debug_info_id_"	+	static_int	+
						"'>";
	code			+=	"<pre style='padding:0;margin:0;'>";
	code			+=	msg;
	code			+=	"</pre>";
	code			+=	"</div>";
	response.print(	code	);
}
/**
 *	书写出日志
 */
var logfile	=	"log.txt";
function log(msg){
	handle.exec(	"INSERT INTO log( msg) "	+
					"VALUES('"	+	msg	+	"')");
}
function error(msg){
	handle.exec(	"INSERT INTO error( msg) "	+
					"VALUES('"	+	msg	+	"')");
}
var handle = new sqlite.Database("log.db");
if ( handle.opened ){ 
	var pragmaStmt = handle.prepare("PRAGMA user_version"); 
	var pragma = pragmaStmt.fetchArray(); 
	if ( pragma[0] == 0 ){
		handle.exec(	"CREATE TABLE log(id INTEGER PRIMARY KEY, " + 
						"msg TEXT)");
		handle.exec(	"CREATE TABLE error(id INTEGER PRIMARY KEY, " + 
						"msg TEXT)");
		handle.exec(	"PRAGMA user_version = 1");
	} 
}else{
	handle = null;
}
